package com.manor.paradise.activity

import android.content.Context
import android.content.Intent
import com.manor.common.activity.AbsActivity
import com.manor.common.utils.KLog
import com.manor.paradise.R
import com.manor.paradise.bean.ParadiseInfoBean
import kotlinx.android.synthetic.main.activity_jz.*
import java.math.BigDecimal

/**
 * 奖章列表
 */
class JzActivity : AbsActivity() {
    override fun getLayoutId(): Int {
        return R.layout.activity_jz
    }

    companion object {
        fun forward(context: Context, item: ParadiseInfoBean) {
            val intent = Intent(context, JzActivity::class.java)
            intent.putExtra("jz", item)
            context.startActivity(intent)
        }
    }


    var paradiseInfoBean: ParadiseInfoBean? = null;
    override fun main() {
        super.main()
        setTitle("淘米奖章")
        if (null != intent && null != intent.getSerializableExtra("jz")) {
            paradiseInfoBean = intent.getSerializableExtra("jz") as ParadiseInfoBean
        }
        paradiseInfoBean?.run {
            KLog.e("ZXCVBN",this)
            if (npc.compareTo(BigDecimal("1")) == 0) {
                im_5.setImageResource(R.mipmap.pic_y_jz5)
                tv5.isSelected = true
            }
            if (npc.compareTo(BigDecimal("2")) == 0) {
                im_6.setImageResource(R.mipmap.pic_y_jz6)
                tv6.isSelected = true
            }
            if(paradiseInfoBean?.bright.equals("2")){
                when (star) {
                    0 -> {
                        im_1.setImageResource(R.mipmap.pic_y_jz0)
                        tv0.isSelected = true
                    }
                    1 -> {
                        im_2.setImageResource(R.mipmap.pic_y_jz1)
                        tv1.isSelected = true
                    }
                    2 -> {
                        im_3.setImageResource(R.mipmap.pic_y_jz2)
                        tv2.isSelected = true
                    }
                    3 -> {
                        im_4.setImageResource(R.mipmap.pic_y_jz3)
                        tv3.isSelected = true
                    }
//                    4 -> {
//                        im_x.setImageResource(R.mipmap.pic_y_jz4)
//                        tv4.isSelected = true
//                    }

                }
            }else{
                when (star) {
                    0 -> {
                        im_1.setImageResource(R.mipmap.pic_y_jz0)
                        tv0.isSelected = true
                    }
                    1 -> {
                        im_1.setImageResource(R.mipmap.pic_y_jz0)
                        im_2.setImageResource(R.mipmap.pic_y_jz1)
                        tv0.isSelected = true
                        tv1.isSelected = true
                    }
                    2 -> {
                        im_1.setImageResource(R.mipmap.pic_y_jz0)
                        im_2.setImageResource(R.mipmap.pic_y_jz1)
                        im_3.setImageResource(R.mipmap.pic_y_jz2)
                        tv0.isSelected = true
                        tv1.isSelected = true
                        tv2.isSelected = true
                    }
                    3 -> {
                        im_1.setImageResource(R.mipmap.pic_y_jz0)
                        im_2.setImageResource(R.mipmap.pic_y_jz1)
                        im_3.setImageResource(R.mipmap.pic_y_jz2)
                        im_4.setImageResource(R.mipmap.pic_y_jz3)
                        tv0.isSelected = true
                        tv1.isSelected = true
                        tv2.isSelected = true
                        tv3.isSelected = true
                    }
                    4 -> {
                        im_1.setImageResource(R.mipmap.pic_y_jz0)
                        im_2.setImageResource(R.mipmap.pic_y_jz1)
                        im_3.setImageResource(R.mipmap.pic_y_jz2)
                        im_4.setImageResource(R.mipmap.pic_y_jz3)
//                        im_x.setImageResource(R.mipmap.pic_y_jz4)
                        tv0.isSelected = true
                        tv1.isSelected = true
                        tv2.isSelected = true
                        tv3.isSelected = true
//                        tv4.isSelected = true
                    }



                }
            }

        }

    }




    override fun onDestroy() {

        super.onDestroy()
    }

}